<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <link rel="stylesheet" type="text/css" href="EasyUI/themes/cupertino/easyui.css">
        <link rel="stylesheet" type="text/css" href="EasyUI/themes/icon.css">
        <link rel="stylesheet" type="text/css" href="css/tabela.css">

        <script type="text/javascript" src="JScript/jquery-1.7.1.min.js"></script>
        <script type="text/javascript" src="EasyUI/locale/easyui-lang-br.js"></script>
        <script type="text/javascript" src="EasyUI/jquery.easyui.min.js"></script>
        <script type="text/javascript" src="JScript/reports.js"></script>
    </head>
    <?php
    // Set flag that this is a parent file.
    define('_JEXEC', 1);
    define('DS', DIRECTORY_SEPARATOR);
    define('JPATH_BASE', dirname(dirname(__FILE__)));

    require_once JPATH_BASE . DS . 'includes' . DS . 'defines.php';
    require_once JPATH_BASE . DS . 'includes' . DS . 'framework.php';

    require_once 'classes/class.ConexaoBD.php';

    $app = JFactory::getApplication('site');
    $app->initialise();

    $session = JFactory::getSession();
    $session_id = $session->get('user_id', 'empty');

    $ClsDB = new ConexaoBD;

    $sql = "SELECT * FROM dados_cadastrais DC ";
    $sql .= "INNER JOIN orcamentos O ON O.id_obra = DC.id ";
    $sql .= "WHERE DC.id_joomla = $session_id ";

    try {
        #$query = $db->prepare($sql);
        #$query->execute();
        $result = $ClsDB->ExecutarQry($sql, 'S');
        #$result = $query->fetchAll();
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    ?>
    <body>
        <table id="ListaOrcs">
            <thead>
                <td>Orçamento</td>
                <td>Nome da Obra</td>
                <td>Engo. Responsável</td>
                <td>Responsável</td>
                <td>Imprimir</td>
                <td>Editar</td>
                <td>Base Novo Orc</td>
            </thead>
            <?php while($row = mysql_fetch_assoc($result)): ?>
            <tr>
                <td>
                    <?php echo $row['num_orcamento']; ?>
                </td>
                <td>
                    <?php echo $row['nome_obra']; ?>
                </td>                
                <td>
                    <?php echo $row['engenheiro_resp']; ?>
                </td>
                <td>
                    <?php echo $row['construtora_resp']; ?>
                </td>                
                
                <?php if($row['aceito'] == 1){ ?>
                    <td><a class="easyui-linkbutton" href="javascript:void(0)" onclick="ReimpEstimativa(<?php echo $row['id_obra']; ?>)">Imprimir</a></td>
                <?php } else { ?>
                    <td>Não Aceito</td>
                <?php } ?>

                <td><a class="easyui-linkbutton" href="Orcamento.php?IdObra=<?php echo $row['id_obra']; ?>&IdOrc=<?php echo $row['num_orcamento']; ?>&OrcAceito=<?php echo $row['aceito']; ?>&IdJoomla=<?php echo $session_id; ?>">Editar</a></td>
                <td><a class="easyui-linkbutton" href="CadObras.php?IdObra=<?php echo $row['id_obra']; ?>&IdOrc=<?php echo $row['num_orcamento']; ?>">Base Novo Orc</a></td>
            </tr>
            <?php endwhile; ?>
        </table>
    </body>
</html>